<template>
  <div class="channel-display views-container">
    <div class="main">
      <div class="content flex-row flex-warp">
        <div
          class="pay-source"
          v-if="patSetting.channel.wechat.open && categoryData && statePower('wechat')"
        >
        <div class="pay-tit wechat flex-row flex-align-c flex-justify-c">
            <p class="big-svg-icon">
                <svg-icon class="pos-center" icon-class="wechat" />
              </p>
            <div class="flex-col">
              <div
                class="header-img"
                v-if="categoryData.wechat"
              >
              <el-popover
                placement="bottom"
                width="200"
                trigger="hover"
              >
                <div class="flex-row flex-align-c flex-justify-c">
                  <img
                    v-if="categoryData.wechat&&categoryData.wechat.qrcode"
                    height="140"
                    width="140"
                    :src="categoryData.wechat.qrcode[0]['file_path']"
                    alt=""
                  >
                </div>
                <div
                  slot="reference"
                  class="ivu-poptip"
                >
                  <div
                    class="code-img-box bll"
                    v-if="categoryData.wechat&&categoryData.wechat.qrcode"
                  >
                    <svg-icon
                        class="icon pos-center"
                        icon-class="erweima"
                        style="font-size:18px;fill:#a8a8a8;"
                      />
                  </div>
                </div>
              </el-popover>
              <img
                  v-if="categoryData.wechat.logo"
                  :src="categoryData.wechat.logo[0]['file_path']"
                  alt=""
                  class="logo"
                >
                <div
                  v-if="!categoryData.wechat.logo"
                  class="img-center"
                  :style="{'background-image':`url(${require('@/assets/custorm_style/default_picture.png')})`}"
                  style="height:70px;width:70px;border-radius:50%;border:1px solid #ebedf0;margin:0 auto;"
                ></div>
              </div>
              <div>微信公众号
                <span
                  class="em"
                  v-if="categoryData.wechat && categoryData.wechat.switch==0"
                >未开启</span>
                <span
                  class="em"
                  v-if="categoryData.wechat && categoryData.wechat.switch==1"
                >已开启</span>
              </div>
              <p>绑定微信公众号，把平台和微信打通</p>
            </div>
          </div>
          <div class="flex-row pay-content flex-warp">
            <div class="flex-col pay-item flex-justify-b">
              <div
                class="flex-row"
                style="width:100%"
              >
                <div
                  class="pay-info"
                  v-if="categoryData.wechat"
                >
                  <el-form
                    v-if="categoryData.wechat.switch==1"
                    :ref="formFormatData.key"
                    :model="formFormatData.formData"
                    :rules="formFormatData.rules"
                    size="small"
                    label-width="110px"
                    class="retail-form"
                    label-position="right"
                  >
                    <el-form-item label="公众号名称">
                      <span style="font-size:12px;">{{categoryData.wechat.name}}</span>
                    </el-form-item>
                    <el-form-item label="公众微信号">
                      <span style="font-size:12px;">{{categoryData.wechat.name}}</span>
                    </el-form-item>
                    <el-form-item label="公众号类型">
                      <span style="font-size:12px;">{{weChatPublicOptions[categoryData.wechat.type]}}</span>
                    </el-form-item>
                  </el-form>
                  <div class="no-channel flex-col flex-align-c flex-justify-c" v-if="categoryData.wechat.switch == 0">
                    <p>配置微信公众号渠道</p>
                    <p>还差一步，就可以开始正式启平台啦</p>
                  </div>
                </div>
              </div>
            <div
              @click="$router.push({path:'/channel/weChatPublicChannel'})"
              class="pay-seting-btn wechat"
            >{{categoryData.wechat && categoryData.wechat.switch==1?'立即管理':'去配置'}}</div>
            </div>
          </div>
        </div>

        <div
          class="pay-source"
          v-if="patSetting.channel.wxapp.open&&categoryData && statePower('wxapp')"
        >
        <div class="pay-tit wxapp flex-row flex-align-c flex-justify-c">
          <p class="big-svg-icon">
                <svg-icon class="pos-center" icon-class="weChatApplets" />
              </p>
            <div class="flex-col">
              <div
                class="header-img"
                v-if="categoryData.sapp"
              >
              <el-popover
                placement="bottom"
                width="200"
                trigger="hover"
              >
                <div class="flex-row flex-align-c flex-justify-c">
                  <img
                    v-if="categoryData.sapp&&categoryData.sapp.qrcode"
                    height="140"
                    width="140"
                    style="margin:0 auto;"
                    :src="categoryData.sapp.qrcode[0]['file_path']"
                    alt=""
                  >
                </div>
                <div
                  slot="reference"
                  class="ivu-poptip"
                >
                  <div
                    class="code-img-box bll"
                    v-if="categoryData.sapp&&categoryData.sapp.qrcode"
                  >
                    <svg-icon
                        class="icon pos-center"
                        icon-class="erweima"
                        style="font-size:18px;fill:#a8a8a8;"
                      />
                  </div>
                </div>
              </el-popover>
              <img
                  v-if="categoryData.sapp.logo"
                  :src="categoryData.sapp.logo[0]['file_path']"
                  alt=""
                  class="logo"
                >
                <div
                  v-if="!categoryData.sapp.logo"
                  class="img-center"
                  :style="{'background-image':`url(${require('@/assets/custorm_style/default_picture.png')})`}"
                  style="height:70px;width:70px;border-radius:50%;border:1px solid #ebedf0;margin:0 auto;"
                ></div>
              </div>
              <div>微信小程序
                <span
                  class="em"
                  v-if="categoryData.sapp && categoryData.sapp.switch==0"
                >未开启</span>
                <span
                  class="em"
                  v-if="categoryData.sapp && categoryData.sapp.switch==1"
                >已开启</span></div>
              <p>绑定微信小程序，把店铺和微信小程序打通</p>
            </div>
          </div>
          <div class="flex-row pay-content flex-warp">
            <div class="flex-col pay-item flex-justify-b">
              <div
                class="flex-row"
                style="width:100%"
              >
                <div
                  class="pay-info"
                  v-if="categoryData.sapp"
                >
                  <el-form
                    v-if="categoryData.sapp.switch==1"
                    :ref="formFormatData.key"
                    :model="formFormatData.formData"
                    :rules="formFormatData.rules"
                    size="small"
                    label-width="130px"
                    class="retail-form"
                    label-position="right"
                  >
                    <el-form-item label="小程序名称">
                      <span style="font-size:12px;">{{categoryData.sapp.name}}</span>
                    </el-form-item>
                    <el-form-item label="绑定号">
                      <span style="font-size:12px;">{{categoryData.sapp.original}}</span>
                    </el-form-item>
                  </el-form>
                  <div class="no-channel flex-col flex-align-c flex-justify-c" v-if="categoryData.sapp.switch == 0">
                    <p>配置微信小程序渠道</p>
                    <p>还差一步，就可以开始正式启平台啦</p>
                  </div>
                </div>
              </div>

            <div
              @click="$router.push({path:'/channel/weChatAppletsChannel'})"
              class="pay-seting-btn wxapp"
            >{{categoryData.sapp && categoryData.sapp.switch==1?'立即管理':'去配置'}}</div>
            </div>
          </div>
        </div>
        <div
          class="pay-source"
          v-if="patSetting.channel.H5.open&&categoryData && statePower('H5')"
        >
        <div class="pay-tit h5 flex-row flex-align-c flex-justify-c">
              <p class="big-svg-icon">
                <svg-icon class="pos-center" icon-class="phoneChannel" />
              </p>
            <div class="flex-col">
              <div
                class="header-img"
                v-if="categoryData.sapp"
              ><img
                  style="background:#fff;"
                  src="@/assets/dashboard/dashbpard_h5.png"
                  alt=""
                  class="logo"
                >
              </div>
              <div>H5
                <span
                  class="em"
                  v-if="categoryData.h5 && categoryData.h5.switch==0"
                >未开启</span>
                <span
                  class="em"
                  v-if="categoryData.h5 && categoryData.h5.switch==1"
                >已开启</span></div>
              <p>开启H5渠道，自动生成H5页面</p>
            </div>
          </div>
          <div class="flex-row pay-content flex-warp">
            <div
              class="flex-col pay-item flex-justify-b"
              v-if="categoryData.h5"
            >
              <img
                v-if="categoryData.h5.qrcode"
                :src="categoryData.h5.qrcode"
                alt=""
                height="80"
                width="80"
              >
              <div
                class="flex-row"
                style="width:70%;margin-top: 10px;"
              >
                <span
                  class="ellipsis"
                  style="width:80%;color:#a8a8a8;"

                >{{categoryData.h5.url}}</span>
                <p
                  @click="handleClipboard(categoryData.h5.url,$event)"
                  v-if="categoryData.h5.url"
                  class="orders-gray copy-link h5"
                >点击复制</p>
              </div>
              <div
              v-if="categoryData.h5"
              @click="changeH5(categoryData.h5.switch)"
              class="pay-seting-btn h5"
            >{{categoryData.h5.switch==0?'开启':'关闭'}}</div>
              <!-- <div class="pay-seting-btn h5">去授权</div> -->
            </div>
          </div>
        </div>

        <div
          class="pay-source"
          v-if="patSetting.channel.aliapp.open&&categoryData && statePower('aliapp')"
        >
        <div class="pay-tit aliapp flex-row flex-align-c flex-justify-c">
              <p class="big-svg-icon">
                <svg-icon class="pos-center" icon-class="channerAlipay" />
              </p>
            <div
              class="flex-col"
            >
            <div
                class="header-img"
                v-if="categoryData.alipay"
              >
              <el-popover
                placement="bottom"
                width="200"
                trigger="hover"
              >
                <div class="flex-row flex-align-c flex-justify-c">
                  <img
                    v-if="categoryData.alipay&&categoryData.alipay.qrcode"
                    height="140"
                    width="140"
                    :src="categoryData.alipay.qrcode[0]['file_path']"
                    alt=""
                  >
                </div>
                <div
                  slot="reference"
                  class="ivu-poptip"
                >
                  <div
                    class="code-img-box bll"
                    v-if="categoryData.alipay&&categoryData.alipay.qrcode"
                  >
                  <svg-icon
                        class="icon pos-center"
                        icon-class="erweima"
                        style="font-size:18px;fill:#a8a8a8;"
                      />
                  </div>
                </div>
              </el-popover>
              <img
                  v-if="categoryData.alipay.logo"
                  :src="categoryData.alipay.logo[0]['file_path']"
                  alt=""
                  class="logo"
                >
                <div
                  v-if="!categoryData.alipay.logo"
                  class="img-center"
                  :style="{'background-image':`url(${require('@/assets/custorm_style/default_picture.png')})`}"
                  style="height:70px;width:70px;border-radius:50%;border:1px solid #ebedf0;margin:0 auto;"
                ></div>
              </div>
              <div v-if="categoryData.alipay">支付宝小程序
                <span
                  class="em"
                  v-if="categoryData.alipay.switch==0"
                >未开启</span>
                <span
                  class="em"
                  v-if="categoryData.alipay.switch==1"
                >已开启</span>
              </div>
              <p>绑定支付宝小程序，把平台和支付宝打通</p>
            </div>
          </div>
          <div class="flex-row pay-content flex-warp">
            <div class="flex-col pay-item flex-justify-b">
              <div
                class="flex-row"
                style="width:100%"
              >
                <div
                  class="pay-info"
                  v-if="categoryData.alipay"
                >
                  <el-form
                    v-if="categoryData.alipay.switch==1"
                    :ref="formFormatData.key"
                    :model="formFormatData.formData"
                    :rules="formFormatData.rules"
                    size="small"
                    label-width="130px"
                    class="retail-form"
                    label-position="right"
                  >
                    <el-form-item label="小程序名称">
                      <span style="font-size:12px;">{{categoryData.alipay.name}}</span>
                    </el-form-item>
                    <el-form-item label="AppId">
                      <span style="font-size:12px;">{{categoryData.alipay.AppId}}</span>
                    </el-form-item>
                  </el-form>
                  <div class="no-channel flex-col flex-align-c flex-justify-c" v-if="categoryData.alipay.switch == 0">
                    <p>配置支付宝小程序渠道</p>
                    <p>还差一步，就可以开始正式启平台啦</p>
                  </div>
                </div>
              </div>
            <div
              @click="$router.push({path:'/channel/alipayAppletsChannel'})"
              class="pay-seting-btn aliapp"
            >{{categoryData.alipay && categoryData.alipay.switch==1 ?'立即管理':'去配置'}}</div>
            </div>
          </div>
        </div>

        <div
          class="pay-source"
          v-if="patSetting.channel.baiduapp.open&&categoryData && statePower('baiduapp')"
        >
        <div class="pay-tit baiduapp flex-row flex-align-c flex-justify-c">
              <p class="big-svg-icon">
                <svg-icon class="pos-center" icon-class="baiduChannel" />
              </p>
            <div
              class="flex-col"
            >
            <div
                class="header-img"
                v-if="categoryData.baidu"
              >
              <el-popover
                placement="bottom"
                width="200"
                trigger="hover"
              >
                <div class="flex-row flex-align-c flex-justify-c">
                  <img
                    v-if="categoryData.baidu&&categoryData.baidu.qrcode"
                    height="140"
                    width="140"
                    :src="categoryData.baidu.qrcode[0]['file_path']"
                    alt=""
                  >
                </div>
                <div
                  slot="reference"
                  class="ivu-poptip"
                >
                  <div
                    class="code-img-box bll"
                    v-if="categoryData.baidu&&categoryData.baidu.qrcode"
                  >
                    <div class='code-img-rotate'>
                      <svg-icon
                        class="icon pos-center"
                        icon-class="erweima"
                        style="font-size:18px;fill:#a8a8a8;"
                      />
                    </div>
                  </div>
                </div>
              </el-popover>
              <img
                  v-if="categoryData.baidu.logo"
                  :src="categoryData.baidu.logo[0]['file_path']"
                  alt=""
                  class="logo"
                >
                <div
                  v-if="!categoryData.baidu.logo"
                  class="img-center"
                  :style="{'background-image':`url(${require('@/assets/custorm_style/default_picture.png')})`}"
                  style="height:70px;width:70px;border-radius:50%;border:1px solid #ebedf0;margin:0 auto;"
                ></div>
              </div>
              <div v-if="categoryData.baidu">百度小程序
                <span
                  class="em"
                  v-if="categoryData.baidu.switch==0"
                >未开启</span>
                <span
                  class="em"
                  v-if="categoryData.baidu.switch==1"
                >已开启</span>
              </div>
              <p>绑定百度小程序，把平台和百度打通</p>
            </div>
          </div>
          <div class="flex-row pay-content flex-warp">
            <div class="flex-col pay-item flex-justify-b">
              <div
                class="flex-row"
                style="width:100%"
              >
                <div
                  class="pay-info"
                  v-if="categoryData.baidu"
                >
                  <el-form
                    v-if="categoryData.baidu.switch==1"
                    :ref="formFormatData.key"
                    :model="formFormatData.formData"
                    :rules="formFormatData.rules"
                    size="small"
                    label-width="130px"
                    class="retail-form"
                    label-position="right"
                  >
                    <el-form-item label="小程序名称">
                      <span style="font-size:12px;">{{categoryData.baidu.name}}</span>
                    </el-form-item>
                    <el-form-item label="AppId">
                      <span style="font-size:12px;">{{categoryData.baidu.AppId}}</span>
                    </el-form-item>
                  </el-form>
                  <div class="no-channel flex-col flex-align-c flex-justify-c" v-if="categoryData.baidu.switch == 0">
                    <p>配置百度小程序渠道</p>
                    <p>还差一步，就可以开始正式启平台啦</p>
                  </div>
                </div>
              </div>
            <div
              @click="$router.push({path:'/channel/baiduAppletsChannel'})"
              class="pay-seting-btn baiduapp"
            >{{categoryData.baidu && categoryData.baidu.switch==1?'立即管理':'去配置'}}</div>
            </div>
          </div>
        </div>

        <div
          class="pay-source"
          v-if="patSetting.channel.toutiaoapp.open&&categoryData && statePower('toutiaoapp')"
        >
        <div class="pay-tit toutiaoapp flex-row flex-align-c flex-justify-c">
              <p class="big-svg-icon">
                <svg-icon class="pos-center" icon-class="toutiao" />
              </p>
            <div
              class="flex-col"
            >
            <div
                class="header-img"
                v-if="categoryData.toutiao"
              >
              <el-popover
                placement="bottom"
                width="200"
                trigger="hover"
              >
                <div class="flex-row flex-align-c flex-justify-c">
                  <img
                    v-if="categoryData.toutiao&&categoryData.toutiao.qrcode"
                    height="140"
                    width="140"
                    :src="categoryData.toutiao.qrcode[0]['file_path']"
                    alt=""
                  >
                </div>
                <div
                  slot="reference"
                  class="ivu-poptip"
                >
                  <div
                    class="code-img-box bll"
                    v-if="categoryData.toutiao&&categoryData.toutiao.qrcode"
                  >
                    <div class='code-img-rotate'>
                      <svg-icon
                        class="icon"
                        icon-class="erweima"
                        style="font-size:18px;fill:#a8a8a8;"
                      />
                    </div>
                  </div>
                </div>
              </el-popover>
              <img
                  v-if="categoryData.toutiao.logo"
                  :src="categoryData.toutiao.logo[0]['file_path']"
                  alt=""
                  class="logo"
                >
                <div
                  v-if="!categoryData.toutiao.logo"
                  class="img-center"
                  :style="{'background-image':`url(${require('@/assets/custorm_style/default_picture.png')})`}"
                  style="height:70px;width:70px;border-radius:50%;border:1px solid #ebedf0;margin:0 auto;"
                ></div>
              </div>
              <div v-if="categoryData.toutiao">头条小程序
                <span
                  class="em"
                  v-if="categoryData.toutiao.switch==0"
                >未开启</span>
                <span
                  class="em"
                  v-if="categoryData.toutiao.switch==1"
                >已开启</span>
              </div>
              <p>绑定头条小程序，把平台和头条打通</p>
            </div>
          </div>
          <div class="flex-row pay-content flex-warp">
            <div class="flex-col pay-item flex-justify-b">
              <div
                class="flex-row"
                style="width:100%"
              >
                <div
                  class="pay-info"
                  v-if="categoryData.toutiao"
                >
                  <el-form
                    v-if="categoryData.toutiao.switch==1"
                    :ref="formFormatData.key"
                    :model="formFormatData.formData"
                    :rules="formFormatData.rules"
                    size="small"
                    label-width="130px"
                    class="retail-form"
                    label-position="right"
                  >
                    <el-form-item label="小程序名称">
                      <span style="font-size:12px;">{{categoryData.toutiao.name}}</span>
                    </el-form-item>
                    <el-form-item label="AppId">
                      <span style="font-size:12px;">{{categoryData.toutiao.AppId}}</span>
                    </el-form-item>
                  </el-form>
                  <div class="no-channel flex-col flex-align-c flex-justify-c" v-if="categoryData.toutiao.switch == 0">
                    <p>配置头条小程序渠道</p>
                    <p>还差一步，就可以开始正式启平台啦</p>
                  </div>
                </div>
              </div>

            <div
              @click="$router.push({path:'/channel/toutiaoAppletsChannel'})"
              class="pay-seting-btn toutiaoapp"
            >{{categoryData.toutiao && categoryData.toutiao.switch==1?'立即管理':'去配置'}}</div>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</template>

<script>
import {
  channelGetAll,
  channelSave
} from '@/api/channel'
import clipboard from '@/utils/clipboard'
export default {
  name: 'EmptyCache',
  created() {
    this.getChanelData()
    this.$nextTick(() => {
      const Base64 = require('js-base64').Base64
      const Cookies = require('js-cookie')
      const storeMenu = Cookies.get('STORE_MENU')
      if (storeMenu && typeof storeMenu === 'string') {
        const storeMenuBase = JSON.parse(Base64.decode(storeMenu))
        console.log(storeMenuBase, 'storeMenuBasestoreMenuBasestoreMenuBase')
        if (!!storeMenuBase && typeof storeMenuBase === 'object') {
          this.patSetting = storeMenuBase
        }
      }
    })
  },
  data() {
    return {
      channelDisplayConfig: {

      },
      categoryData: {},
      h5Data: {},
      weChatPublicOptions: {
        '1': '订阅号',
        '2': '认证订阅号',
        '3': '服务号',
        '4': '认证服务号/认证政府订阅号/认证媒体订阅号'
      },
      patSetting: {
        'channel': {
          'H5': {
            'open': true
          },
          'wechat': {
            'open': true
          },
          'wxapp': {
            'open': true
          },
          'aliapp': {
            'open': true
          },
          'baiduapp': {
            'open': true
          },
          'toutiaoapp': {
            'open': true
          },
          'android': {
            'open': true
          },
          'ios': {
            'open': true
          }
        }
      },
      formFormatData: {
        key: 'userForm',
        formData: {
          apply: { AppId: '',
            aes_key: '',
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            private_key: '',
            public_key: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0'
          },
          baidu: {
            AppId: '',
            AppKey: '',
            AppSecret: '',
            authorized: { url: '' },
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0'
          },
          h5: {
            authorized: { url: '' },
            authorizedAddress: [''],
            qrcode: '',
            url: '',
            switch: '0'
          },
          sapp: {
            AppId: '',
            AppSecret: '',
            authorized: { url: '', EncodingAESKey: '', Token: '', dataType: '' },
            original: '',
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0'
          },
          toutiao: {
            AppId: '',
            AppSecret: '',
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0'
          },
          wechat: {
            AppId: '',
            AppSecret: '',
            authorized: { url: '', EncodingAESKey: '', Token: '' },
            authorizedAddress: [''],
            original: '',
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            type: '',
            url: '',
            url_qrcode: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0'
          }
        }
      }
    }
  },
  computed: {
    statePower() {
      return function(channel) {
        return JSON.stringify(this.$store.getters.power).indexOf(channel) > -1
      }
    }
  },
  methods: {
    getChanelData() {
      // const msgData = {}
      // const { alipay, baidu, h5, sapp, toutiao, wechat } = msgData
      // if (!alipay) {
      //   msgData.alipay = { AppId: '',
      //     aes_key: '',
      //     logo: [{ file_id: '',
      //       file_name: '',
      //       file_path: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     name: '',
      //     private_key: '',
      //     public_key: '',
      //     qrcode: [{ file_id: '',
      //       file_name: '',
      //       file_path: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     switch: '0' }
      // }
      // if (!baidu) {
      //   msgData.baidu = {
      //     AppId: '',
      //     AppKey: '',
      //     AppSecret: '',
      //     authorized: { url: '' },
      //     logo: [{ file_id: '',
      //       file_name: '',
      //       file_path: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     name: '',
      //     qrcode: [{ file_id: '',
      //       file_name: '',
      //       file_path: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     switch: '0' }
      // }
      // if (!h5) {
      //   msgData.h5 = {
      //     authorized: { url: '' },
      //     authorizedAddress: [''],
      //     qrcode: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //     url: 'authorizedAddress',
      //     switch: '0' }
      // }
      // if (!sapp) {
      //   msgData.sapp = {
      //     AppId: '',
      //     AppSecret: '',
      //     authorized: { url: '', EncodingAESKey: '', Token: '', dataType: '' },
      //     original: '',
      //     logo: [{ file_id: '',
      //       file_name: '',
      //       file_path: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     name: '',
      //     qrcode: [{ file_id: '',
      //       file_name: '',
      //       file_path: '',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     switch: '0' }
      // }
      // if (!toutiao) {
      //   msgData.toutiao = {
      //     AppId: '',
      //     AppSecret: '',
      //     logo: [{ file_id: '',
      //       file_name: '',
      //       file_path: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //       file_type: '',
      //       file_url: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //       storage: '' }],
      //     name: '',
      //     qrcode: [{ file_id: '',
      //       file_name: '',
      //       file_path: '',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     switch: '0' }
      // }
      // if (!wechat) {
      //   msgData.wechat = {
      //     AppId: '',
      //     AppSecret: '',
      //     authorized: { url: '', EncodingAESKey: '', Token: '' },
      //     authorizedAddress: [''],
      //     original: '',
      //     logo: [{ file_id: '',
      //       file_name: '',
      //       file_path: 'https://devwe7.weliam.cn/addons/weliam_areashop/web/uploads/1/image/2019/05/20190527144153cf8552317.jpg',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     name: '',
      //     type: '',
      //     url: '',
      //     url_qrcode: '',
      //     qrcode: [{ file_id: '',
      //       file_name: '',
      //       file_path: '',
      //       file_type: '',
      //       file_url: '',
      //       storage: '' }],
      //     switch: '0' }
      // }
      // this.categoryData = msgData
      // this.h5Data = msgData.h5
      channelGetAll().then((response) => {
        const {
          data: {
            data: msgData = []
          }
        } = response
        const { alipay, baidu, h5, sapp, toutiao, wechat } = msgData
        if (!alipay) {
          msgData.alipay = { AppId: '',
            aes_key: '',
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            private_key: '',
            public_key: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0' }
        }
        if (!baidu) {
          msgData.baidu = {
            AppId: '',
            AppKey: '',
            AppSecret: '',
            authorized: { url: '' },
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0' }
        }
        if (!h5) {
          msgData.h5 = {
            authorized: { url: '' },
            authorizedAddress: [''],
            qrcode: '',
            url: '',
            switch: '0' }
        }
        if (!sapp) {
          msgData.sapp = {
            AppId: '',
            AppSecret: '',
            authorized: { url: '', EncodingAESKey: '', Token: '', dataType: '' },
            original: '',
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0' }
        }
        if (!toutiao) {
          msgData.toutiao = {
            AppId: '',
            AppSecret: '',
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0' }
        }
        if (!wechat) {
          msgData.wechat = {
            AppId: '',
            AppSecret: '',
            authorized: { url: '', EncodingAESKey: '', Token: '' },
            authorizedAddress: [''],
            original: '',
            logo: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            name: '',
            type: '',
            url: '',
            url_qrcode: '',
            qrcode: [{ file_id: '',
              file_name: '',
              file_path: '',
              file_type: '',
              file_url: '',
              storage: '' }],
            switch: '0' }
        }
        this.categoryData = msgData
        this.h5Data = msgData.h5
      })
    },
    changeH5(val) {
      channelSave({ type: 'h5', channel: { h5: { switch: val === '1' ? '0' : '1', authorized: this.h5Data.authorized, authorizedAddress: this.h5Data.authorizedAddress, qrcode: this.h5Data.qrcode, url: this.h5Data.url } } }).then((response) => {
        const { data: { msg, code } } = response
        if (code === 1) {
          this.$message.success('修改成功')
          this.getChanelData()
        } else {
          this.$message.error(msg)
        }
      })
    },
    handleClipboard(text, event) {
      clipboard(text, event)
    }
  }
}
</script>

<style lang="scss" scoped>
.channel-display {
  $wechat-style: rgb(77, 190, 46);
  $wxapp-style: rgb(119, 137, 217);
  $h5-style: rgb(244, 151, 14);
  $aliapp-style: rgb(9, 170, 232);;
  $baiduapp-style: rgb(51, 136, 255);
  $toutiaoapp-style: rgb(229, 35, 24);

  $wechat-sub-style: rgb(56, 140, 33);
  $wxapp-sub-style: rgb(51, 77, 190);
  $h5-sub-style: rgb(169, 109, 20);
  $aliapp-sub-style: rgb(9, 122, 165);
  $baiduapp-sub-style: rgb(15, 76, 162);
  $toutiaoapp-sub-style: rgb(157, 15, 7);

  @mixin colorBtn() {
    display: inline-block;
    height: 18px;
    line-height: 18px;
    padding: 0 6px;
    font-size: 12px;
    border-radius: 9px;
    font-style: normal;
    margin-left: 5px;
  }

  .code-img-box {
    position: absolute;
    overflow: hidden;
    cursor: pointer;
    background: #ffffff;
    right: -38px;
    top: 28px;
    z-index: 3;
    height: 25px;
    border-radius: 2em;
    width: 25px;
  }
  /deep/ .pay-info {
    width:100%;
    .no-channel{
      margin-top: 40px;
    }
  }
  /deep/ .pay-info .retail-form .el-form-item__label {
    color: rgb(168,168,168);
    font-size: 12px;
  }

  /deep/ .pay-info .retail-form .el-form-item {
    margin-bottom: 0px;
    height: 40px;
    line-height: 40px;
  }
  .big-svg-icon {
    position: absolute;
    bottom: 0;
    top: 0;
    left: 0;
    right: 0;
  }
  .big-svg-icon svg {
    fill: rgba(255, 255, 255, 0.1);
    font-size: 20em;
  }
  .header-img .qr-code {
    display: block;
    width: 24px;
    height: 24px;
    line-height: 23px;
    border-radius: 50%;
    background-color: #fff;
    -webkit-box-shadow: 0 0 10px #e5e5e5;
    box-shadow: 0 0 10px #e5e5e5;
    text-align: center;
  }

  .header-img {
    position: relative;
    margin-bottom: 5px;
    margin-top: 15px;
    &+div{
      margin-top:5px;
    }
  }

  .header-img img.logo {
    display: block;
    width: 70px;
    height: 70px;
    border: 2px solid #fff;
    border-radius: 50%;
    margin: 0 auto;
  }

  .header-img .ivu-poptip {
    position: absolute;
    top: 20px;
    right: 50%;
    transform: translateX(130%);
  }

  .main {
    width: 100%;
    min-height: calc(100vh - 90px);
    border-radius: 4px;
    background: #ffffff;

    .content {
      padding-top: 90px;

      .pay-source {
        margin-bottom: 90px;
        margin-left: 28px;
        width: 378px;
        border: 1px solid #eee;
        background: #fff;
        border-radius: 10px;
        $pay-font-color: #ffffff;
        position: relative;

        .pay-tit {
          position: relative;
          height: 170px;
          background: #f3f4f7;
          padding: 0 20px 10px;
          background-position: center;
          background-size: cover;
          background-repeat: no-repeat;
          border-radius: 10px 10px 0 0;
          &.wechat {
            .em {
              @include colorBtn;
              background-color: $wechat-sub-style;
            }
            background-color: $wechat-style;
          }

          &.wxapp {
            .em {
              @include colorBtn;
              background-color: $wxapp-sub-style;
            }

            background-color: $wxapp-style;
          }

          &.aliapp {
            .em {
              @include colorBtn;
              background-color: $aliapp-sub-style;
            }

            background-color: $aliapp-style;
          }

          &.baiduapp {
            .em {
              @include colorBtn;
              background-color: $baiduapp-sub-style;
            }

            background-color: $baiduapp-style;
          }

          &.toutiaoapp {
            .em {
              @include colorBtn;
              background-color: $toutiaoapp-sub-style;
            }

            background-color: $toutiaoapp-style;
          }

          &.h5 {
            .em {
              @include colorBtn;
              background-color: $h5-sub-style;
            }

            background-color: $h5-style;
          }

          div {
            &:not(.code-img-box){
              color: $pay-font-color;
            font-size: 18px;
            text-align: center;
            &.pay-set {
              /deep/ {
                .el-button--text {
                  color: $pay-font-color;
                  background: none;
                  border: none;
                }
              }

              align-self: flex-end;
              padding-bottom: 3px;
            }
            }
          }

          p {
            font-size: 12px;
            color: $pay-font-color;
            &:not(.big-svg-icon) {
              margin-top: 5px;
            }
          }
        }

        .pay-seting-btn {
            width: 175px;
            color: #ffffff;
            border-radius: 5px;
            height: 35px;
            line-height: 35px;
            padding: 0 10px;
            letter-spacing: 1px;
            margin: 10px 0 5px;
            font-size: 12px;
            text-align: center;
            cursor: pointer;
            &.wechat {
              background: $wechat-style;
            }

            &.wxapp {
              background: $wxapp-style;
            }

            &.aliapp {
              background: $aliapp-style;
            }

            &.baiduapp {
              background: $baiduapp-style;
            }

            &.toutiaoapp {
              background: $toutiaoapp-style;
            }

            &.h5 {
              background: $h5-style;
            }
          }

        .pay-content {
          height: 210px;
          padding:20px 0
        }
      }

      .pay-content {
        .copy-link{
          cursor: pointer;
          &.h5{
            color: $h5-style;
          }
        }
        .pay-item {
          width: 100%;
          -webkit-box-align: center;
          -webkit-align-items: center;
          -ms-flex-align: center;
          align-items: center;

          .pay-icon-box {
            width: 36px;
            height: 36px;
            line-height: 36px;
            text-align: center;
            border-radius: 5px;
            background: rgb(35, 25, 220);

            &.gray {
              background: rgb(204, 204, 204);
            }

            svg {
              vertical-align: middle;
              width: 31px;
              height: 31px;
              fill: #fff;
            }
          }

          .pay-icon {
            width: 36px;
            height: 36px;
          }
        }
      }
    }
  }

  .main-text {
    margin-top: 30px;
  }
}
</style>
